import requests


class Dog:
    def __init__(self,name,color,size):
        self.name = name
        self.color = color
        self.size = size


    def music(self,params):
        baidu = requests.get(url='https://www.baidu.com/',params=params)
        print('正在播放中',baidu)
        print(self.name,self.color,self.size)

    def jump(self):
        pass
class JinMao(Dog):
    def jump(self):
        print('没事跳一跳')



class Person:
    def play(self,dog,params):
        dog.jump()
        dog.music(params)
if __name__ == '__main__':
    p1 = Person()
    jm = JinMao('金毛','黄','大')
    p1.play(jm,'baidu')


class MusicPlayer:
    #1.记录实例对象
    instance = None
    #2.记录是否初始化
    flag = False
    #3.__new__方法为对象分配空间
    def __new__(cls, *args, **kwargs):
        if cls.instance == None:
            #调用父类分配空间
            cls.instance = super().__new__(cls)
        #返回实例对象
        return cls.instance
    #4.init 初始化函数
    def __init__(self):
        if MusicPlayer.flag == False:

            MusicPlayer.flag = True

if __name__ == '__main__':
    m1 = MusicPlayer()
    m2 = MusicPlayer()
    print(m1,m2,m1==m2)